package com.huiquan.icd.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.huiquan.framework.base.EnhancedBaseDao;
import com.huiquan.icd.domain.IcdDiseaseSymptomDescription;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository
public class IcdDiseaseSymptomDescriptionDao extends EnhancedBaseDao<IcdDiseaseSymptomDescription> {

	@Resource(name = "sqlMapClient")
	private SqlMapClient sqlMapClient;

	public static final String space = "ICD_DISEASE_SYMPTOM_DESCRIPTION.";

	public IcdDiseaseSymptomDescriptionDao() {
		super(space);
	}

	/**
	 * 获取数据总数
	 * 
	 * @return
	 */
	public int checkRepeat(String array, String partPattern, String descriptionId,String id) {
		Map<String, Object> param = new HashMap<>();
		param.put("array", array);
		param.put("partPattern", partPattern);
		param.put("description_id", descriptionId);
		param.put("id", id);
		Integer size = (Integer) this.object(space + "CHECK_REPEAT", param, sqlMapClient);
		return size == null ? 0 : size;
	}

	public void updateCheckFlag(String id, String flag) {
		Map<String, Object> param = new HashMap<>();
		param.put("id", id);
		param.put("flag", flag);
		update(space + "UPDATE_CHECK_FLAG", param, sqlMapClient);
	}

	public void updateArray(String id, String arr, String part, Long userId) {
		Map<String, Object> param = new HashMap<>();
		param.put("id", id);
		param.put("arr", arr);
		param.put("part", part);
		param.put("uid", userId);
		update(space + "UPDATE_ARRAY", param, sqlMapClient);
	}

	/**
	 * 根据一个Map自定义获取列表
	 * 
	 * @param param
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<IcdDiseaseSymptomDescription> retrieveDescriptionSplitList(String id) {
		Map<String, Object> param = new HashMap<>();
		param.put("id", id);
		return (List<IcdDiseaseSymptomDescription>) this.list(space + "RETRIEVE_DESCRIPTION_SPLIT_LIST_BY_ID", param,
				sqlMapClient);
	}
	

	/**
	 * 根据id获取对象
	 * @param id
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public Map<String, Object> retrieveSplitById(Long id) {
		Map<String, Object> param = new HashMap<>();
		param.put("id", id);
		return (Map<String, Object>)this.object(space + "RETRIEVE_SPLIT_BY_ID", param, sqlMapClient);
	}
}
